<?php
//namespace Core;

defined('ENV') || exit('illegal Access! @110');
class Load
{
    //自动加载，目录改为小写，类名区分大小写
    public static function Common($class)
    {
        $str = str_replace('\\', '/', $class);
        $arr = explode('/', $str);
        $file = array_pop($arr); //类名
        $dir = strtolower(implode('/', $arr));//目录
        $realpath = ROOT.$dir.'/'.$file.PHP_FILE_EXTENSION;
        if (file_exists($realpath)) {
            include_once($realpath);
        }
    }

    //自动加载，目录和类名都区分大小写
    public static function CommonCi($class)
    {
        $str = str_replace('\\', '/', $class);
        $realpath = realpath(ROOT.$str.PHP_FILE_EXTENSION);
        if (file_exists($realpath)) {
            include_once($realpath);
        }
    }

    //用于加载统一模块下的类文件
    public static function Module($class)
    {
        $file = ltrim($class, '_');
        $realpath = realpath(MODULEPATH.MODULE_NAME.'/'.$file.PHP_FILE_EXTENSION);
        if (file_exists($realpath)) {
            include_once($realpath);
        }
    }
}